package com.easy.base.api.model.entity;

import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonFormat;

import org.hibernate.annotations.GenericGenerator;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@MappedSuperclass
public class BaseEntity {

    public BaseEntity(String id) {
        this.id = id;
    }

    @Id
    @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator")
    @GeneratedValue(generator = "idGenerator")
    @ApiModelProperty("ID")
    private String id;

    @ApiModelProperty("状态")
    private boolean valid;

    @Column(name = "create_by", updatable = false)
    @ApiModelProperty
    private String createBy;

    @Column(name = "create_date", updatable = false)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty("创建日期")
    private Timestamp createDate;

    @Column(name = "update_by")
    @ApiModelProperty
    private String updateBy;

    @Column(name = "update_date")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty("更新日期")
    private Timestamp updateDate;

    @Transient
    @ApiModelProperty("当前页码")
    private int current;

    @Transient
    @ApiModelProperty("每页数量")
    private int pageSize;
}
